package com.sunyard.domee.service.convert;

import com.google.common.collect.Lists;
import com.sunyard.domee.dal.dataobject.MarketingCouponDO;
import com.sunyard.domee.service.bo.MarketingCouponBO;
import org.apache.commons.collections.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * 优惠券
 *
 * @author xw
 * @email wei.xiao  çæææ
 * @date 2020-07-02 22:52:45
 */
public class MarketingCouponConvert {

	public static MarketingCouponBO toBO(MarketingCouponDO marketingCouponDO) {
		if (marketingCouponDO == null) {
			return null;
		}
		MarketingCouponBO marketingCouponBO = new MarketingCouponBO();
		marketingCouponBO.setId(marketingCouponDO.getId());
		marketingCouponBO.setCouponName(marketingCouponDO.getCouponName());
		marketingCouponBO.setCouponType(marketingCouponDO.getCouponType());
		marketingCouponBO.setDiscountMax(marketingCouponDO.getDiscountMax());
		marketingCouponBO.setAmountFullMax(marketingCouponDO.getAmountFullMax());
		marketingCouponBO.setDiscount(marketingCouponDO.getDiscount());
		marketingCouponBO.setLimitNum(marketingCouponDO.getLimitNum());
		marketingCouponBO.setEffectiveDate(marketingCouponDO.getEffectiveDate());
		marketingCouponBO.setEffectiveStartDate(marketingCouponDO.getEffectiveStartDate());
		marketingCouponBO.setEffectiveEndDate(marketingCouponDO.getEffectiveEndDate());
		marketingCouponBO.setCouponStatus(marketingCouponDO.getCouponStatus());
		marketingCouponBO.setCreaterCode(marketingCouponDO.getCreaterCode());
		marketingCouponBO.setUpdateTime(marketingCouponDO.getUpdateTime());
		marketingCouponBO.setCreateTime(marketingCouponDO.getCreateTime());
		marketingCouponBO.setUpdateCode(marketingCouponDO.getUpdateCode());
		marketingCouponBO.setDelFlag(marketingCouponDO.getDelFlag());
		return marketingCouponBO;
	}

	public static MarketingCouponDO toDO(MarketingCouponBO marketingCouponBO) {
		if (marketingCouponBO == null) {
			return null;
		}
		MarketingCouponDO marketingCouponDO = new MarketingCouponDO();
		marketingCouponDO.setId(marketingCouponBO.getId());
		marketingCouponDO.setCouponName(marketingCouponBO.getCouponName());
		marketingCouponDO.setCouponType(marketingCouponBO.getCouponType());
		marketingCouponDO.setDiscountMax(marketingCouponBO.getDiscountMax());
		marketingCouponDO.setAmountFullMax(marketingCouponBO.getAmountFullMax());
		marketingCouponDO.setDiscount(marketingCouponBO.getDiscount());
		marketingCouponDO.setLimitNum(marketingCouponBO.getLimitNum());
		marketingCouponDO.setEffectiveDate(marketingCouponBO.getEffectiveDate());
		marketingCouponDO.setEffectiveStartDate(marketingCouponBO.getEffectiveStartDate());
		marketingCouponDO.setEffectiveEndDate(marketingCouponBO.getEffectiveEndDate());
		marketingCouponDO.setCouponStatus(marketingCouponBO.getCouponStatus());
		marketingCouponDO.setCreaterCode(marketingCouponBO.getCreaterCode());
		marketingCouponDO.setUpdateTime(marketingCouponBO.getUpdateTime());
		marketingCouponDO.setCreateTime(marketingCouponBO.getCreateTime());
		marketingCouponDO.setUpdateCode(marketingCouponBO.getUpdateCode());
		marketingCouponDO.setDelFlag(marketingCouponBO.getDelFlag());
		return marketingCouponDO;
	}

	public static List<MarketingCouponBO> toBOList(List<MarketingCouponDO> doList) {
        if (CollectionUtils.isEmpty(doList)) {
			return Collections.emptyList();
		}
		List<MarketingCouponBO> boList = Lists.newArrayList();
		for (MarketingCouponDO marketingCouponDO : doList) {
			if (marketingCouponDO != null) {
				boList.add(toBO(marketingCouponDO));
			}
		}
		return boList;
	}

	public static List<MarketingCouponDO> toDOList(List<MarketingCouponBO> boList) {
        if (CollectionUtils.isEmpty(boList)) {
            return Collections.emptyList();
		}

		List<MarketingCouponDO> doList = Lists.newArrayList();
		for (MarketingCouponBO marketingCouponBO : boList) {
			if (marketingCouponBO != null) {
				doList.add(toDO(marketingCouponBO));
			}
		}
		return doList;
	}

}
